#include <gflags/gflags.h>

#include "speech_server.hpp"

DEFINE_bool(debug, true, "默认开启debug模式");
DEFINE_string(logPath, "", "发布模式下，日志路径");
DEFINE_int32(logLevel, 0, "发布模式下，日志级别");

DEFINE_string(api_id, "117794142", "百度语音API ID");
DEFINE_string(api_key, "dj8daZARulLR6L5kldb2wePk", "百度语音API key");
DEFINE_string(api_secret, "eAf0m906BiBHWysNvyOCOrUIvmeTpDT6", "百度语音API secret");

DEFINE_string(SpeechHost, "http://127.0.0.1:2379", "etcd的IP地址");
DEFINE_string(baseService, "/service", "服务监控根目录");
DEFINE_string(instanceName, "/speech_service/instance", "语音转文字服务名称");
DEFINE_string(accessHost, "127.0.0.1:10001", "当前实例的外部访问地址");

DEFINE_int32(listenPort, 10001, "Rpc服务器监听端口");
DEFINE_int32(rpcTimeout, -1, "Rpc调用超时时间");
DEFINE_int32(rpcThreads, 1, "Rpc的IO线程数量");

int main(int argc, char* argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, true);
    im::initLogger(FLAGS_debug, FLAGS_logPath, FLAGS_logLevel);

    im::SpeechServerBuild build;
    build.init_asr_client(FLAGS_api_id, FLAGS_api_key, FLAGS_api_secret);
    build.init_register_client(FLAGS_SpeechHost, FLAGS_baseService + FLAGS_instanceName, FLAGS_accessHost);
    build.init_rpc_server(FLAGS_listenPort, FLAGS_rpcTimeout, FLAGS_rpcThreads);
    im::SpeechServer::ptr ssr = build.build();
    ssr->start();
    return 0;
}